package com.nbjtjc.safe.api.sys;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.sys.SysTeam;
import com.nbjtjc.safe.service.sys.SysTeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @auther guqianbin
 * @date 2018/6/21 9:48
 **/
@RestController
@RequestMapping("/team")
@CrossOrigin("*")
public class SysTeamController {
    @Autowired
    private SysTeamService sysTeamService;

    @PostMapping("/find")
    public Result find(SysTeam sysTeam){
        Result result=new Result();
        result=sysTeamService.find(sysTeam);
        return result;
    }

    @PostMapping("/add")
    public Result add(SysTeam sysTeam){
        ValidatorUtils.validateEntity(sysTeam);
        Result result=new Result();
        result=sysTeamService.add(sysTeam);
        return result;
    }

    @PostMapping("/update")
    public Result update(SysTeam sysTeam){
        ValidatorUtils.validateEntity(sysTeam,UpdateGroup.class,Default.class);
        Result result=new Result();
        result=sysTeamService.update(sysTeam);
        return result;
    }

    @PostMapping("/delete")
    public Result delete(SysTeam sysTeam){
        ValidatorUtils.validateEntity(sysTeam,UpdateGroup.class);
        Result result=new Result();
        result=sysTeamService.delete(sysTeam);
        return result;
    }
}
